package leetcode.editor.week.week306;

public class Solution6148 {
    // https://leetcode.cn/problems/largest-local-values-in-a-matrix/
    public int[][] largestLocal(int[][] grid) {
        int n = grid.length;
        int[][] res = new int[n - 2][n -2];
        for(int i = 0; i < n - 2; i++) {
            for(int j = 0; j < n - 2; j++) {
                int max = 0;
                for(int k = i; k < i + 3; k++) {
                    for(int m = j; m < j + 3; m++) {
                        max = Math.max(max, grid[k][m]);
                    }
                }
                res[i][j] = max;
            }
        }

        return res;
    }}
